<template>
  <button ref="_ref" class="my-button" :class="{
    [`my-button--${type}`]: type,
    [`my-button--${size}`]: size,
    'is-plain': plain,
    'is-round': round,
    'is-circle': circle,
    'is-disabled': disabled,
    'is-loading': loading
  }" :disabled="disabled || loading" :autofocus="autofocus" :type="nativeType">
    <Icon icon="fa-solid fa-spinner" spin v-if="loading" />
    <Icon :icon="icon" v-if="icon" />
    <span>
      <slot></slot>
    </span>
  </button>
</template>

<script setup lang="ts">
import { ref } from "vue"
import type { ButtonProps } from "./types";
import Icon from '../Icon/Icon.vue'
defineOptions({
  name: 'MyButton'
})
withDefaults(defineProps<ButtonProps>(), {
  nativeType: 'button'
})
const _ref = ref<HTMLButtonElement>()
defineExpose({
  ref: _ref
})
</script>

<style lang="scss" scoped></style>